/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.inspur.edp.lcm.metadata.inner.api.data;

import lombok.Data;
import lombok.experimental.Accessors;

@Data
@Accessors(chain = true)
public class PublishStatus {
    /**
     * 0: 正常  1：发生错误
     */
    private Integer status;
    /**
     * 进度值(0-100)
     */
    private Integer process;
    /**
     * 当前所属阶段 1：编译应用 2：打包应用 3：部署应用
     */
    private Integer stage;
    /**
     * 发生错误时的错误信息
     */
    private String errorMsg;
    /**
     * 是否需要重启 0：未重启  1：重启
     */
    private int reStart = 0;

    private PublishStatus() {

    }

    private PublishStatus(Integer status, Integer process, Integer stage, String errorMsg) {
        this.status = status;
        this.process = process;
        this.stage = stage;
        this.errorMsg = errorMsg;
    }

    public static PublishStatus success(int process, int stage) {
        return new PublishStatus(0, process, stage, null);
    }

    public static PublishStatus fail(String errorMsg) {
        return new PublishStatus(1, null, null, errorMsg);
    }
}
